/***********************************************************************
 * Module:  RoadSectionController.java
 * Author:  Administrator
 * Purpose: Defines the Class RoadSectionController
 ***********************************************************************/

package ishitong.configManagement.controller;

import ishitong.vehicle.common.model.Section;
import ishitong.commons.pagination.Pagination;
import ishitong.vehicleManagement.service.biz.impl.SPIRoadSectionService;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.ishitong.platform.common.page.Page;

/** @pdOid b79a9e59-f0f9-40ce-b111-63c97be14cb9 */
@Controller
public class RoadSectionController extends ishitong.common.controller.ActionController {
   /** @pdOid 8a3623b1-eab7-4d46-ac9a-e6f53d504cc3 */
   private static final String ROA_SEC_SCH = "/configManagement/roadSection/roadSectionSearch";
   /** @pdOid 24925c02-deea-4363-80be-e4b440770a80 */
   private static final String ROA_SEC_SCH_LST = "/configManagement/roadSection/roadSectionSearchList";
   /** @pdOid 4c547416-63d9-4c81-8469-1dae54c21be4 */
   private static final String ROA_SEC_EDT = "/configManagement/roadSection/roadSectionEdit";
   /** @pdOid 629a5c31-4edb-4ad0-8462-98ba38768793 */
   private static final String ROA_SEC_VIW = "/configManagement/roadSection/roadSectionView";
   /** @pdOid 3f955e38-2671-4781-8eff-68039707828c */
   @Autowired
   private SPIRoadSectionService spiRoadSectionService;
   
   /** @param request
    * @exception Exception
    * @pdOid e9d79ddc-2b19-4ee1-880d-ddd21fa0455e */
   @RequestMapping(value = "/showRoadSectionSearch.do")
   public ModelAndView handleShowRoadSectionSearch(HttpServletRequest request) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		return new ModelAndView(ROA_SEC_SCH, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param roadSection 
    * @param pagination
    * @pdOid 7213eb67-0fe3-496f-ab90-04d4c5dea536 */
   @RequestMapping(value = "/ajaxRoadSectionSearchList.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxFindRoadSectionSearchList(HttpServletRequest request, Section roadSection, Pagination pagination) {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		Page<Section> page = spiRoadSectionService.findPage(roadSection, pagination);
   		model.put("page", page);
   		return new ModelAndView(ROA_SEC_SCH_LST, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param roadSectionId 
    * @param response
    * @exception Exception
    * @pdOid ba6ee5f1-ebda-4c6f-b843-81005c2ec292 */
   @RequestMapping(value = "/ajaxShowRoadSectionEdit.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowRoadSectionEdit(HttpServletRequest request, String roadSectionId, HttpServletResponse response) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		if (!StringUtils.isEmpty(roadSectionId)) {
   			Section section = spiRoadSectionService.findById(roadSectionId);
   			model.put("section", section);
   		}
   		return new ModelAndView(ROA_SEC_EDT, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param section 
    * @param response
    * @exception Exception
    * @pdOid e5a69c6f-204d-4ed5-8028-28038b6570c7 */
   @RequestMapping(value = "/ajaxSaveRoadSection.do", method = RequestMethod.POST)
   public void handleAjaxSaveRoadSection(HttpServletRequest request, Section section, HttpServletResponse response) throws Exception {
   	try {
   		spiRoadSectionService.saveSection(section);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }
   
   /** @param request 
    * @param roadSectionId
    * @exception Exception
    * @pdOid 7a16e387-45b5-4c11-aa33-08c79df43ee2 */
   @RequestMapping(value = "/ajaxShowRoadSectionView.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowRoadSectionView(HttpServletRequest request, String roadSectionId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		if (!StringUtils.isEmpty(roadSectionId)) {
   			Section section = spiRoadSectionService.findById(roadSectionId);
   			model.put("section", section);
   		}
   		return new ModelAndView(ROA_SEC_VIW, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param roadSectionIds 
    * @param response
    * @exception Exception
    * @pdOid 86d81cad-af3c-43c3-a88c-feae339e8884 */
   @RequestMapping(value = "/ajaxDeleteRoadSectionByIds.do", method = RequestMethod.POST)
   public void handleAjaxDeleteRoadSectionByIds(HttpServletRequest request, String roadSectionIds, HttpServletResponse response) throws Exception {
   	try {
   		spiRoadSectionService.deleteSectionById(roadSectionIds);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }

}